package com.example.interceptor.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 项目配置文件
 */
@Configuration
//public class AppConfig implements WebMvcConfigurer {
public class AppConfig extends WebMvcConfigurationSupport {
    /**
     * 添加拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**") // 拦截所有地址
                .excludePathPatterns("/**.html"); // 不拦截所有的 html 页
        super.addInterceptors(registry);
    }
}
